<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Insert title here</title>

<link href="../bootstrap/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
html {
	padding: 10px 20px 10px 20px;
}
</style>
</head>
<body>
	<div class="panel panel-default">
		<div class="panel-heading">文章修改</div>
		<div class="panel-body">
			<form id="formPost" class="form-horizontal" action="${action}" method="post" enctype="multipart/form-data">
				<input type="hidden" name="id" value="${id }" >
				
				<div class="form-group">
					<label for="title" class="col-sm-2 control-label">文章标题</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="title" 
								name="title" value="${title}">
					</div>
				</div>
				<div class="form-group">
					<label for="created" class="col-sm-2 control-label">创建时间</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="created" name="created"
							value='<fmt:formatDate value="${created}" pattern="yyyy-MM-dd"/>' 
						>
					</div>
				</div>
				<div class="form-group">
					<label for="category" class="col-sm-2 control-label">文章分类</label>
					<div class="col-sm-2">
						<select class="form-control" id="category" name="category.id">
							<option value="-1">请选择分类：</option>
							<c:forEach items="${categories}" var="c" >
								<c:choose>
									<c:when test="${post.category.id == c.id }" >
										<option value="${c.id }" selected>${c.name }</option>
									</c:when>
									<c:otherwise>
										<option value="${c.id }">${c.name }</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="content" class="col-sm-2 control-label">文章内容</label>
					<div class="col-sm-10">
						<textarea class="form-control" id="content" rows="4" 
									name="content" value="${content}">
						</textarea>
					</div>
				</div>
				<div class="form-group">
					<label for="postImage" class="col-sm-2 control-label">文章封面</label>
					<div class="col-sm-10">
						<input type="file" class="form-control-file" name="uploadFile" id="postImage">
					</div>
				</div>

				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="submit" class="btn btn-primary"
							style="width: 100px;">提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>

	<script src="../js/jquery.min.js"></script>
	<script src="../bootstrap/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function () {
			// $('#formPost').submit(function(){
			// 	alert("aaaa");
			// 	var url="../post/edit";
			// 	window.location=url;

			// })
			console.log("${categories}");

		})

	</script>
</body>
</html>